#lang racket/base
(require
 (for-syntax
  racket/base
  spire/core/transformers/infix)
 "util/check-expansion.rkt"
 rackunit)

(begin-for-syntax
  (struct simple-infix [fixity]
    #:property prop:infix-transformer
    (λ (self stx)
      (simple-infix-fixity self))))

(define-syntax <: (simple-infix 'right))
(define-syntax :> (simple-infix 'left))
(define-syntax == #f)

(check-expansion
 (a)
 a
 rewrite-infix->prefix)

(check-expansion
 (a == b)
 (== a b)
 rewrite-infix->prefix)

(check-expansion
 (a :> b :> c)
 (:> (:> a b) c)
 rewrite-infix->prefix)

(check-expansion
 (a <: b <: c)
 (<: a (<: b c))
 rewrite-infix->prefix)

(check-expansion-exn
 (a == b == c)
 #px"cannot chain operator"
 rewrite-infix->prefix)

(check-expansion-exn
 (a :> b <: c)
 #px"mixing .+ unsupported"
 rewrite-infix->prefix)
